<template>
  <div class="login">
    <div id="main-box"></div>
    <div id="main-content">
      <div class="login-body animated fadeInLeft">
        <div class="login-main pr">
          <form class="login-form">
            <h3>weteach后台管理</h3>
            <h5 style="padding-bottom: 10px">Weatch System Management</h5>
            <!-- 账号登陆 -->
            <div id="MobileBox" class="item-box">
              <div class="input-group user-name">
                <span class="input-group-addon"><i class="icon-user"></i></span>
                <el-input placeholder="请输入账号" v-model="input_acount" clearable>
                </el-input>
              </div>
              <div class="input-group password">
                <span class="input-group-addon"><i class="icon-lock"></i></span>
                <el-input placeholder="请输入密码" v-model="input_pass" show-password clearable></el-input>
              </div>
            </div>

            <div class="login_btn_panel">
              <el-button @click="adminLogin" type="primary">Login</el-button>
              <div class="check-tips"></div>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { Login } from "network/login";
import { mapState, mapMutations } from "vuex";
import axios from 'axios'
import { setCookie, getCookie } from "util/myCookie";
export default {
  name: "Login",
  data() {
    return {
      input_acount:'admin001',
      input_pass:'123456',
      ipKey:'7155e1de441a6ebb1edeb932f148a59f'//ip接口的key
    }
  },
  mounted() {
    console.log("royter:", this.$route);
    this.changePublicNav(false);
  },
  destroyed() {
    this.changePublicNav(true);
  },
  methods: {
    ...mapMutations(["changePublicNav","judgeisLogin"]),
       generateAddress(str){
    let arr = str.split(',')
    let newArr = []
    let reg = /\"([^\"]*)[^\x00-\xff]\"/gm
    for(let i = 0;i<arr.length;i++){
        let Narr = arr[i].match(reg)
        console.log("narr:",Narr)
        newArr.push(Narr[0].replace(/\"/gm,''))
    }
    return newArr;
},
    adminLogin(){
      let that = this;
      that.$eventBus.$emit("userLogin",'登录操作')
      this.judgeisLogin(true);
      Login(this.input_acount,this.input_pass).then(res=>{
        console.log("后台响应：",res);
        if(res.status!=400){
          setCookie("user",res.user,10);
          let time = new Date().toLocaleDateString() + ' ' + new Date().toLocaleTimeString()
          setCookie("time",time,10);
          this.$message({
          message: '登录成功!',
          type: 'success',
          duration:1500
        });
          setTimeout(()=>{
            that.$router.push('/home');
          },1500)
        }
        // 
      })
    }
  },
};
</script>

<style  scoped>
.login {
  width: 100vw;
  height: 100vh;
  background-image: url(~@/assets/img/loginBG.jpg);
}
body,
html {
  font-size: 14px;
  font-family: "微软雅黑", Helvetica, Tahoma, Arial, sans-serif;
  color: #000;
  height: 100%;
  background-position: center;
  background-attachment: fixed;
  background-size: cover;
}
img {
  border: 0;
}
.cf:after,
.cf:before {
  display: table;
  content: "";
}
.cf:after {
  clear: both;
}

/* #main-content{background:url(../images/dot.png);height:100%} */
#main-box {
  width: 100%;
  height: 100%;
  z-index: 1;
  background-color: rgba(0, 0, 0, 0.95);
  background-image: -webkit-linear-gradient(left, transparent 0, #1b1f27 100%);
  background-image: -o-linear-gradient(left, transparent 0, #1b1f27 100%);
  background-image: linear-gradient(to right, transparent 0, #1b1f27 100%);
  background-repeat: repeat-x;
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00000000', endColorstr='#ff1b1f27', GradientType=1);
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
  opacity: 0.3;
}

.login-body {
  padding: 20px;
  position: fixed;
  z-index: 2;
  left: 50%;
  top: 50%;
  margin-top: -300px;
  margin-left: -200px;
  border-radius: 5px;
  width: 400px;
  position: absolute;
  top: 50%;
  left: 50%;
  background-color: rgba(38, 43, 54, 0.9);
  padding: 20px;
  z-index: 300;
}
.login-body .pr {
  position: relative;
}
.login-form {
  width: 370px;
  margin: 0 auto;
  padding: 20px 30px 13px 23px;
}
.login-form .input-group {
  margin-bottom: 15px;
  border-radius: 4px;
}
.login-form .input-group .input-group-addon {
  width: 43px;
  border: none;
  background: #fff;
}
.login-form .input-group .input-group-addon i {
  color: rgba(38, 43, 54, 0.9);
  font-size: 24px;
}
.login-form .input-group > input {
  border: none;
  border-left: none;
  padding: 10px 20px;
  color: grey;
  height: auto;
}
.login-form .input-group .btn {
  background-color: #fff;
  border: none;
  font-size: 24px;
  padding: 6px 14px;
}
.login-form h3 {
  font-size: 26px;
  font-weight: 500;
  padding: 0;
  line-height: 30px;
  text-align: center;
  color: #259dab;
}
.login-form h5 {
  font-size: 20px;
  font-weight: 400;
  line-height: 30px;
  text-align: center;
  color: #259dab;
  border-bottom: 1px solid #555;
  padding-bottom: 10px;
}
.login-form h5 ul {
  margin-top: 8px;
}
.login-form h5 a {
  font-size: 14px;
  color: #fff;
}
.login-form .check-tips {
  color: red;
  margin-top: 10px;
}
.login-form .item-box {
  margin-top: 18px;
}
.login-form .item-box .item {
  border-radius: 5px;
}
.login-form .item {
  padding: 3px 10px 3px 12px;
  border: 1px solid #ececec;
  background-color: #fff;
  margin-bottom: 10px;
}
.login-form .focus {
  border: 1px solid #a6e1f3;
  box-shadow: 0 0 12px #baf7ff;
}
.login-form .login_btn_panel {
  margin: 20px 0 10px;
}
.login-form .login_btn_panel button {
  border: none;
}
.login-form .login-btn {
  border-radius: 3px;
}
.login-form .login-btn[disabled] {
  opacity: 0.6;
  filter: alpha(opacity=60);
  cursor: default;
  box-shadow: none;
}
.login-form .login-btn .in {
  display: none;
}
.login-form .log-in .in {
  display: inline-block;
}
.login-form .log-in .on {
  display: none;
}
.icon-loading {
  display: inline-block;
  margin-right: 5px;
  width: 16px;
  height: 16px;
  vertical-align: -3px;
  background: url(~@/assets/img/loading.gif) no-repeat 0 0;
}
input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px #fff inset;
}
img.verifyimg {
  border-radius: 3px;
  cursor: pointer;
  position: absolute;
  right: 0;
  z-index: 99;
  border-radius: 0 4px 4px 0;
}
.input-group .form-control:not(:first-child):not(:last-child) {
  border-radius: 0 4px 4px 0;
}
.login-form .input-group {
  width: 319px;
}
.login-main input {
  box-shadow: none;
  border: none;
  border-radius: 0 4px 4px 0;
}

.use-mobile-a {
  margin-top: 20px;
}
.use-qrcode-a {
  margin-top: 20px;
  text-align: right;
}
</style>